package display;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import deckbuilder.Flashcard;

public class Style1 
{
	public Style1()
	{
		
	}
	
	public void buildGUI()
	{
		final JFrame frame = new JFrame();
		JPanel card = new JPanel();
		JPanel buttons = new JPanel();
		JPanel space = new JPanel();
		JPanel result = new JPanel();
		
		GridBagConstraints c = new GridBagConstraints();
		
		JButton show = new JButton("SHOW");
		JButton next = new JButton("NEXT");
		JButton yes = new JButton("YES");
		JButton no = new JButton("NO");
		
		JTextField text = new JTextField(20);
		

		JLabel answer = new JLabel("Your answer:");
		JLabel question = new JLabel("Did you get the answer right?");
		
		final Flashcard flashcards = new Flashcard();
		flashcards.deck.buildDeckFromFile("test.txt");
		flashcards.newLabels();
		
		frame.setLayout(new GridBagLayout());
		frame.setSize(350, 200);
		frame.setLocationRelativeTo(null);
		
		flashcards.term.setVisible(true);
		flashcards.def.setVisible(false);
		  
	    c.gridx = 0;
	    c.gridy = 0;
		frame.add(card, c);
		
	    c.gridx = 0;
	    c.gridy = 1;
		frame.add(buttons, c);
		
		c.gridx = 0;
	    c.gridy = 2;
		frame.add(space, c);
		
		c.gridx = 0;
	    c.gridy = 3;
		frame.add(result, c);
		
		card.add(flashcards.term);
		card.add(flashcards.def);
		
		buttons.add(show);
		buttons.add(next);
		
		space.add(answer);
		space.add(text);
		
		result.add(question);
		result.add(yes);
		result.add(no);
		
		frame.setVisible(true);

		show.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent arg0) {
					flashcards.swapLabels();
			}
		});

		next.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent arg0) {
				flashcards.nextCard();
				flashcards.newLabels();
			}
		});
	}
}
